#include<bits/stdc++.h>
using namespace std;
int T;
int n,ans=0;
int a[200005];
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>T;
    for(int i=0;i<T;i++){
        cin>>n;
        for(int j=0;j<n;j++){
            cin>>a[j];
        }
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                if(a[j]==a[k]&&j!=k)ans++;
            }
        }
        cout<<ans<<" ";
        ans=0;
    }

    return 0;
}
